Optimal. Leaf size=179 \[ -\frac {2 a^2 (d \cos (e+f x))^n \, _2F_1\left (\frac {1}{2},\frac {n}{2};\frac {2+n}{2};\cos ^2(e+f x)\right ) \sin (e+f x)}{f n \sqrt {\sin ^2(e+f x)}}-\frac {a^2 (1-2 n) \cos (e+f x) (d \cos (e+f x))^n \, _2F_1\left (\frac {1}{2},\frac {1+n}{2};\frac {3+n}{2};\cos ^2(e+f x)\right ) \sin (e+f x)}{f (1-n) (1+n) \sqrt {\sin ^2(e+f x)}}+\frac {a^2 (d \cos (e+f x))^n \tan (e+f x)}{f (1-n)} \]
[Out]
________________________________________________________________________________________
Rubi [A]
time = 0.16, antiderivative size = 179, normalized size of antiderivative = 1.00, number of steps
used = 7, number of rules used = 5, integrand size = 23, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.217, Rules used = {4349, 3873,
3857, 2722, 4131} \begin {gather*} -\frac {2 a^2 \sin (e+f x) (d \cos (e+f x))^n \, _2F_1\left (\frac {1}{2},\frac {n}{2};\frac {n+2}{2};\cos ^2(e+f x)\right )}{f n \sqrt {\sin ^2(e+f x)}}-\frac {a^2 (1-2 n) \sin (e+f x) \cos (e+f x) (d \cos (e+f x))^n \, _2F_1\left (\frac {1}{2},\frac {n+1}{2};\frac {n+3}{2};\cos ^2(e+f x)\right )}{f (1-n) (n+1) \sqrt {\sin ^2(e+f x)}}+\frac {a^2 \tan (e+f x) (d \cos (e+f x))^n}{f (1-n)} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 2722
Rule 3857
Rule 3873
Rule 4131
Rule 4349
Rubi steps
\begin {align*} \int (d \cos (e+f x))^n (a+a \sec (e+f x))^2 \, dx &=\left ((d \cos (e+f x))^n (d \sec (e+f x))^n\right ) \int (d \sec (e+f x))^{-n} (a+a \sec (e+f x))^2 \, dx\\ &=\left ((d \cos (e+f x))^n (d \sec (e+f x))^n\right ) \int (d \sec (e+f x))^{-n} \left (a^2+a^2 \sec ^2(e+f x)\right ) \, dx+\frac {\left (2 a^2 (d \cos (e+f x))^n (d \sec (e+f x))^n\right ) \int (d \sec (e+f x))^{1-n} \, dx}{d}\\ &=\frac {a^2 (d \cos (e+f x))^n \tan (e+f x)}{f (1-n)}+\frac {\left (2 a^2 \left (\frac {\cos (e+f x)}{d}\right )^{-n} (d \cos (e+f x))^n\right ) \int \left (\frac {\cos (e+f x)}{d}\right )^{-1+n} \, dx}{d}+\frac {\left (a^2 (1-2 n) (d \cos (e+f x))^n (d \sec (e+f x))^n\right ) \int (d \sec (e+f x))^{-n} \, dx}{1-n}\\ &=-\frac {2 a^2 (d \cos (e+f x))^n \, _2F_1\left (\frac {1}{2},\frac {n}{2};\frac {2+n}{2};\cos ^2(e+f x)\right ) \sin (e+f x)}{f n \sqrt {\sin ^2(e+f x)}}+\frac {a^2 (d \cos (e+f x))^n \tan (e+f x)}{f (1-n)}+\frac {\left (a^2 (1-2 n) \left (\frac {\cos (e+f x)}{d}\right )^{-n} (d \cos (e+f x))^n\right ) \int \left (\frac {\cos (e+f x)}{d}\right )^n \, dx}{1-n}\\ &=-\frac {2 a^2 (d \cos (e+f x))^n \, _2F_1\left (\frac {1}{2},\frac {n}{2};\frac {2+n}{2};\cos ^2(e+f x)\right ) \sin (e+f x)}{f n \sqrt {\sin ^2(e+f x)}}-\frac {a^2 (1-2 n) \cos (e+f x) (d \cos (e+f x))^n \, _2F_1\left (\frac {1}{2},\frac {1+n}{2};\frac {3+n}{2};\cos ^2(e+f x)\right ) \sin (e+f x)}{f (1-n) (1+n) \sqrt {\sin ^2(e+f x)}}+\frac {a^2 (d \cos (e+f x))^n \tan (e+f x)}{f (1-n)}\\ \end {align*}
________________________________________________________________________________________
Mathematica [C] Result contains complex when optimal does not.
time = 1.38, size = 266, normalized size = 1.49 \begin {gather*} \frac {i 2^{-2-n} a^2 e^{-i (e+f x)} \left (e^{-i (e+f x)} \left (1+e^{2 i (e+f x)}\right )\right )^{-1+n} \cos ^{-n}(e+f x) (d \cos (e+f x))^n (1+\cos (e+f x))^2 \left (4 e^{2 i (e+f x)} (-1+n) n \, _2F_1\left (1,\frac {n}{2};2-\frac {n}{2};-e^{2 i (e+f x)}\right )+\left (1+e^{2 i (e+f x)}\right ) (-2+n) \left (4 e^{i (e+f x)} n \, _2F_1\left (1,\frac {1+n}{2};\frac {3-n}{2};-e^{2 i (e+f x)}\right )+\left (1+e^{2 i (e+f x)}\right ) (-1+n) \, _2F_1\left (1,\frac {2+n}{2};1-\frac {n}{2};-e^{2 i (e+f x)}\right )\right )\right ) \sec ^4\left (\frac {1}{2} (e+f x)\right )}{f (-2+n) (-1+n) n} \end {gather*}
Warning: Unable to verify antiderivative.
[In]
[Out]
________________________________________________________________________________________
Maple [F]
time = 0.11, size = 0, normalized size = 0.00 \[\int \left (d \cos \left (f x +e \right )\right )^{n} \left (a +a \sec \left (f x +e \right )\right )^{2}\, dx\]
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {Failed to integrate} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {could not integrate} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} a^{2} \left (\int \left (d \cos {\left (e + f x \right )}\right )^{n}\, dx + \int 2 \left (d \cos {\left (e + f x \right )}\right )^{n} \sec {\left (e + f x \right )}\, dx + \int \left (d \cos {\left (e + f x \right )}\right )^{n} \sec ^{2}{\left (e + f x \right )}\, dx\right ) \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \text {could not integrate} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [F]
time = 0.00, size = -1, normalized size = -0.01 \begin {gather*} \int {\left (d\,\cos \left (e+f\,x\right )\right )}^n\,{\left (a+\frac {a}{\cos \left (e+f\,x\right )}\right )}^2 \,d x \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________